package com.sql.dao;

import com.sql.model.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * Created by 走过全世界。 on 2017/5/30 0030.
 */
public interface UserMapping {

    @Select("select * from user where id=#{id}")
    public User getUserById(Integer id);

    @Select("select * from user where username=#{username}")
    public User getUserByUsername(String username);

    @Insert("insert into user(username,password,id_number,email,phone,permission) values(#{user.username}," +
            "#{user.password}," +
            "#{user.id_number}," +
            "#{user.email}," +
            "#{user.phone}," +
            "#{user.permission})")
    @Options(useGeneratedKeys = true, keyProperty = "user.id")
    public Integer insertNewUser(@Param("user") User user);

}
